package com.eightbears.beboy.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.eightbears.beboy.R;
import com.eightbears.beboy.base.util.CommonUtils;
import com.eightbears.beboy.entity.ShopAccountEntity;

import static com.eightbears.beboy.R.id.tv_date;

/**
 * Created by Administrator on 2017/9/4.
 */

public class ShopAccountAdapter extends BaseQuickAdapter<ShopAccountEntity.AccountBalance, BaseViewHolder> {

    public ShopAccountAdapter() {
        super(R.layout.item_shop_account);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, ShopAccountEntity.AccountBalance accountBalance) {

        View view_data_title = baseViewHolder.getView(R.id.view_data_title);
        view_data_title.setVisibility(View.GONE);
        if(!TextUtils.isEmpty(accountBalance.getTotalBalance())) {
            view_data_title.setVisibility(View.VISIBLE);
            baseViewHolder.setText(R.id.tv_date, CommonUtils.TimeStamp2Date(accountBalance.getCreated_at(), "yyyy-MM-dd"))
                    .setText(R.id.tv_in, accountBalance.getTotalBalance())
                    .addOnClickListener(R.id.ll_calendar);
        }

        baseViewHolder.setText(R.id.tv_title, accountBalance.getTitle())
                .setText(R.id.tv_money, accountBalance.getBalance())
                .setText(tv_date, CommonUtils.TimeStamp2Date(accountBalance.getCreated_at(), "yyyy-MM-dd HH:mm"));

        CommonUtils.loadImageView(mContext, accountBalance.getLogo(),
                R.mipmap.default_icon, (ImageView) baseViewHolder.getView(R.id.iv_logo));
    }

}
